<template>
<Form ref="form" :model="form" :rules="rule" :label-width="80">
  <FormItem label="姓名" prop="realName">
    <Input v-model="form.realName" placeholder="">
    </Input>
  </FormItem>
  <FormItem label="手机" prop="mobilePhone">
    <Input v-model="form.mobilePhone" placeholder="">
    </Input>
  </FormItem>
  <FormItem label="邮箱" prop="email">
    <Input v-model="form.email" placeholder="">
    </Input>
  </FormItem>
  <FormItem label="电话" prop="telephone">
    <Input v-model="form.telephone" placeholder="">
    </Input>
  </FormItem>
  </FormItem>
</Form>
</template>
<script>
import { updateInfo, getInfo } from '@/api/ums/ums.personal.service.js'
export default {
  data () {
    return {
      form: {
        realName: '',
        email: '',
        telephone: '',
        mobilePhone: ''
      },
      rule: {
        email: [
          { required: false, type: 'email', message: '邮箱不合法', trigger: 'blur' }
        ],
        realName: [
          { required: true, message: '姓名不能为空', trigger: 'blur' }
        ],
        mobilePhone: [
          { required: true, message: '手机号不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  mounted () {
    getInfo({
    }).then(res => {
      this.form = this.$util.copy(res.data, this.form)
    })
  },
  methods: {
    submit () {
      return new Promise((resolve, reject) => {
        this.$refs['form'].validate((valid) => {
          if (valid) {
            updateInfo(this.form).then(res => {
              resolve(res)
            }).catch(e => {
              reject(e)
            })
          } else {
            reject(new Error('error'))
          }
        })
      })
    }
  }
}
</script>
